/**
 * @author Caius
 * @description
 *      实现数据库直接操作的Dao层实现
 * @version 1.0
 * @since Created in 2024-12-09
 */

package com.itsense.lib_sys.dao;

import com.itsense.lib_sys.model.Book;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface BookDao {
    //实现增删改查
    //添加
    @Insert("insert into booklist(title, author, description) values (#{title}, #{author}, #{description})")
    int save(Book book);
    //删除
    @Delete("delete from booklist where id = #{id}")
    int deleteById(Integer id);
    //修改
    @Update("update booklist set title =#{title} , author = #{author}, description = #{description} where id = #{id}")
    int update(Book book);
    //通过id查看数据
    @Select("select * from booklist where id = #{id}")
    Book getById(Integer id);
    //返回所有数据实现
    @Select("select * from booklist")
    List<Book> getAllBook();
}
